package com.jlnk.petdemo.repository;

import com.jlnk.petdemo.entity.PetResponse;
import com.jlnk.petdemo.network.PetApiService;

import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class PetRepository {
    private PetApiService petApiService;
    private static final String BASE_URL = "http://apis.juhe.cn/";
    private static final String API_KEY = "59dd288e33815232f6b7ad694863e75e";

    public PetRepository() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        petApiService = retrofit.create(PetApiService.class);
    }

    public void getPetList(String name, int type, int page, int num, Callback<PetResponse> callback) {
        petApiService.getPetList(API_KEY, name, type, page, num).enqueue(callback);
    }
}